home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / drivers / trid8916.asm < prev    next >
Assembly Source File  |  1993-12-06  |  4KB  |  230 lines

  1. ; This is file TRIDNT89.ASM
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. include grdriver.inc
  16. cseg    segment byte public 'code'
  17.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  18.  
  19.     dw    offset init_routine
  20.     dw    offset paging_routine
  21.     dw    GRD_VGA+GRD_4_PLANES+GRD_1024K+GRD_NO_RW
  22.  
  23. def_tw  dw    80    ; filled in by go32 if GO32 env. var. is set
  24. def_th  dw    25
  25. def_gw  dw    640
  26. def_gh  dw    480
  27.  
  28. ;--------------------------------------------------------------------------
  29. ; Entry: AX=mode selection
  30. ;        0=80x25 text
  31. ;        1=default text
  32. ;        2=text CX cols by DX rows
  33. ;        3=biggest text
  34. ;        4=320x200 graphics
  35. ;        5=default graphics
  36. ;        6=graphics CX width by DX height
  37. ;        7=biggest non-interlaced graphics
  38. ;        8=biggest graphics
  39. ;
  40. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  41. ;
  42. ; Exit:  CX=width (in pixels or characters)
  43. ;     DX=height
  44.  
  45. init_table    label    word
  46.     dw    offset init_0
  47.     dw    offset init_1
  48.     dw    offset init_2
  49.     dw    offset init_3
  50.     dw    offset init_4
  51.     dw    offset init_5
  52.     dw    offset init_6
  53.     dw    offset init_7
  54.     dw    offset init_8
  55.  
  56. init_routine    proc    far
  57.     cmp    ax,8
  58.     jbe    valid_req
  59.     ret
  60. valid_req:
  61.     shl    ax,1
  62.     mov    bx,ax
  63.     jmp    init_table[bx]
  64.  
  65. init_0: ; 80x25 text
  66.     mov    ax,3
  67.     int    10h
  68.     mov    cx,80
  69.     mov    dx,25
  70.     ret
  71.  
  72. init_1: ; default text
  73.     mov    cx,def_tw
  74.     mov    dx,def_th
  75.     jmp    init_2
  76.  
  77. init_2_table    label    word
  78.     dw    01h, 40, 25
  79.     dw    03h, 80, 25
  80.     dw    50h, 80, 30
  81.     dw    51h, 80, 43
  82.     dw    52h, 80, 60
  83.     dw    53h, 132, 25
  84.     dw    54h, 132, 30
  85.     dw    55h, 132, 43
  86.     dw    56h, 132, 60
  87. init_2_tend    label    word
  88.  
  89. init_2: ; CX*DX text
  90.     mov    si,offset init_2_table
  91. init_2a:
  92.     cmp    [si+2],cx
  93.     jb    init_2b
  94.     cmp    [si+4],dx
  95.     jb    init_2b
  96.     ; got a big enough one!
  97.     jmp    init_2c
  98. init_2b:
  99.     cmp    si,offset init_2_tend - 6
  100.     je    init_2c
  101.     add    si,6
  102.     jmp    init_2a
  103. init_2c:
  104.     mov    ax,[si]
  105.     push    si
  106.     int    10h
  107.     pop    si
  108.     mov    cx,[si+2]
  109.     mov    dx,[si+4]
  110.     ret
  111.  
  112. init_3: ; biggest text
  113.     mov    ax,[init_2_tend-6]
  114.     int    10h
  115.     mov    cx,[init_2_tend-4]
  116.     mov    dx,[init_2_tend-2]
  117.     ret
  118.  
  119. init_4: ; 320x200 graphics
  120.     mov    ax,0dh
  121.     int    10h
  122.     mov    cx,320
  123.     mov    dx,200
  124.     ret
  125.  
  126. init_5: ; default graphics - should be 640x480 if supported
  127.     mov    cx,def_gw
  128.     mov    dx,def_gh
  129.     jmp    init_6
  130.  
  131. init_6_table    label    word
  132.     dw    0dh, 320, 200
  133.     dw    12h, 640, 480
  134.     dw    5bh, 800, 600
  135.     dw    5fh, 1024, 768
  136. init_6_tend    label    word
  137.  
  138. init_6: ; CX*DX graphics
  139.     mov    si,offset init_6_table
  140. init_6a:
  141.     cmp    [si+2],cx
  142.     jb    init_6b
  143.     cmp    [si+4],dx
  144.     jb    init_6b
  145.     ; got a big enough one!
  146.     jmp    init_6c
  147. init_6b:
  148.     cmp    si,offset init_6_tend - 6
  149.     je    init_6c
  150.     add    si,6
  151.     jmp    init_6a
  152. init_6c:
  153.     mov    ax,[si]
  154.     push    si
  155.     int    10h
  156.     pop    si
  157.     mov    cx,[si+2]
  158.     mov    dx,[si+4]
  159.     ret
  160.  
  161. init_7: ; biggest non-interlaced graphics
  162.     mov    ax,5bh
  163.     int    10h
  164.     mov    cx,800
  165.     mov    dx,600
  166.     ret
  167.  
  168. init_8: ; biggest graphics
  169.     mov    ax,5fh
  170.     int    10h
  171.     mov    cx,1024
  172.     mov    dx,768
  173.     ret
  174.  
  175. init_routine    endp
  176.  
  177. ;--------------------------------------------------------------------------
  178. ; Entry: AH=read page
  179. ;     AL=write page
  180. ;
  181. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  182. ; This code must be relocatable and may not reference any data!
  183. ;
  184. ; Exit: VGA configured.
  185. ;    AX,BX,CX,DX,SI,DI may be trashed
  186. ;
  187. ; Code derived from VGAKIT version 3.4
  188. ;    Copyright 1988,89,90 John Bridges
  189.  
  190.     assume  ds:nothing, es:nothing
  191.  
  192. paging_routine  proc    far
  193.     mov    cx,ax        ;save page
  194.     mov    dx,3ceh        ;set pagesize to 64k
  195.     mov    al,6
  196.     out    dx,al
  197.     inc    dl
  198.     in    al,dx
  199.     dec    dl
  200.     or    al,4
  201.     mov    ah,al
  202.     mov    al,6
  203.     out    dx,ax
  204.  
  205.     mov    dl,0c4h        ;switch to BPS mode
  206.     mov    al,0bh
  207.     out    dx,al
  208.     inc    dl
  209.     in    al,dx
  210.     dec    dl
  211.  
  212.     mov    ah,cl
  213.     xor    ah,2
  214.     mov    dx,3c4h
  215.     mov    al,0eh
  216.     out    dx,ax
  217.  
  218.     mov    dx,3ceh        ; config GR CTRL port for mask writes
  219.     mov    al,8
  220.     out    dx,al
  221.  
  222.     ret
  223.  
  224. paging_routine  endp
  225.  
  226. ;--------------------------------------------------------------------------
  227.  
  228. cseg    ends
  229.     end
  230.